package com.xiangzuzu;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import jakarta.annotation.Resource;

/**
 * @description
 * @author nx
 * @date 2024/4/6 12:07:09
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                // 对所有请求进行拦截
                .addPathPatterns("/**")
                // 除了登录接口外，其他都需要进行登录校验
                .excludePathPatterns("/login");
    }
}